package com.xxx.common.enums;

import com.xxx.common.enums.base.BaseEnum;
import lombok.Getter;

/**
 * @author Flying
 * @Description
 * @date 18:48 2018-08-16
 **/
public enum LanguageType implements BaseEnum {
    /**
     * 中文
     */
    CN(1,"CN"),
    /**
     * 英文
     */
    EN(2,"EN");

    private final Integer value;

    private final String description;

    LanguageType(Integer value, String description){
        this.value = value;
        this.description = description;
    }

    public static LanguageType valueOf(Integer value) {
        for (LanguageType item : values()) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return null;
    }

    public static LanguageType descriptionOf(String description) {
        for (LanguageType item : values()) {
            if (item.getDescription().equals(description)) {
                return item;
            }
        }
        return null;
    }


    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public LanguageType get(Integer value) {
        return LanguageType.valueOf(value);
    }


    @Override
    public String toString() {
        return String.valueOf(this.value);
    }
}
